package com.example.exception;

import com.example.pojo.VO.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@Slf4j
@RestControllerAdvice
public class GlobalExptionHandler {
    @ExceptionHandler(Exception.class)
    public Result hanleExption(Exception e)
    {
        log.info("异常处理{}",e.getMessage());
        e.printStackTrace();
        return Result.error(StringUtils.hasLength(e.getMessage())?e.getMessage():"操作异常");
    }
}
